package com.ruoyi.common.utils;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter;
import org.springframework.util.AntPathMatcher;

import java.util.*;

/**
 * 字符串工具类
 * 
 * @author ruoyi
 */
public class CodeNumUtils
{

    /****
     * 左侧补0，自动加一
     * @param str 原编号
     * @param size 后缀几位数自增
     * @return
     */
    public static final String  codeNum(String str, int size)
    {
        //先根据size截取后面几个字符
        String codenumold=str.substring(str.length()-size,str.length());
        Integer count=Integer.parseInt(codenumold);
        Integer countres=count+1;
        return StringUtils.padl(countres,size);
    }

    /***
     * 年月日返回固定格式编码
     * @return
     */
    public static String dateString() {
        Calendar calendar = Calendar.getInstance();

        int year = calendar.get(Calendar.YEAR);

        int month = calendar.get(Calendar.MONTH)+1;

        int date = calendar.get(Calendar.DATE);

        int hour = calendar.get(Calendar.HOUR_OF_DAY);

        int minute = calendar.get(Calendar.MINUTE);

        int second = calendar.get(Calendar.SECOND);

        StringBuilder res=new StringBuilder();

        return res.append(year).append(month<10?"0"+month:month).append(date<10?"0"+date:date).append(hour<10?"0"+hour:hour).append(minute<10?"0"+minute:minute).append(second<10?"0"+second:second).toString();
    }


    public static void main(String[] args) {
        System.out.println("args = " + CodeNumUtils.dateString());
    }




}